package ua.com.ulitko.server.dao;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import ua.com.ulitko.client.entity.Performer;
import ua.com.ulitko.client.service.PerformerService;
import ua.com.ulitko.server.dto.AlbumDTO;
import ua.com.ulitko.server.dto.PerformerDTO;
import ua.com.ulitko.server.dto.SongDTO;
import ua.com.ulitko.server.util.TransferDTOUtil;

import java.util.ArrayList;

/**
 * @author suamo ( 31.03.12 23:04 )
 */
public class PerformerDao extends HibernateDaoSupport implements PerformerService {

    @Override
    public ArrayList<Performer> getPerformerList() {
        return TransferDTOUtil.FromDB.transferPerformerList(getHibernateTemplate().find("from PerformerDTO "));
    }

    @Override
    public void addPerformer(Performer entity) {
        PerformerDTO performer = TransferDTOUtil.ToDB.transferPerformer(entity);
        AlbumDTO album = performer.getAlbumList().get(0);
        SongDTO song = album.getSongList().get(0);
        Object ret1 = getHibernateTemplate().save(performer);
        System.out.println(ret1);
    }
}
